package thread;

/**
 * Thread提供了一套获取相关信息的方法
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread mainThread = Thread.currentThread();
        //String getName:获取线程名
        System.out.println("name: " + mainThread.getName());
        //long getId:获取线程的唯一标识
        //唯一标识：用该值唯一表达一个数据，区分你我的
        //可以作为唯一标识使用的值必须同时满足两个条件：非空且唯一
        System.out.println("id: " + mainThread.getId());

        int priority = mainThread.getPriority();
        System.out.println("优先级: "+priority);
        boolean isAlive = mainThread.isAlive();
        System.out.println("isAlive: "+ isAlive);

        boolean isDaemon = mainThread.isDaemon();
        System.out.println("isDamon:" + isDaemon);

        boolean isInterrupted = mainThread.isInterrupted();
        System.out.println("isInterrupted:" + isInterrupted);
    }
}
